package com.example.dameng.controller;

import com.example.dameng.api.CommonResult;
import com.example.dameng.entity.*;
import com.example.dameng.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ResponseBody
@RestController
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/user/personalInfo")
    public CommonResult personalInfo(@RequestParam int userCode){
        PersonalInfo info = userService.getPersonalInfo(userCode);
        System.out.println("--普通用户个人信息测试--");
        System.out.println(info);
        return CommonResult.success(info);
    }


    @GetMapping(value = "/user/consumptionList")
    public CommonResult consumptionList(@RequestParam int userCode,@RequestParam String month){
        System.out.println("---用电查询测试---");
        Double bill = userService.getConsumptionList(userCode,month);
        Double consumeNum = userService.getConsumeNum(userCode,month);

        System.out.println(bill);
        System.out.println(consumeNum);
        ConsumptionList list = new ConsumptionList(bill,consumeNum);
        return CommonResult.success(list);
    }

}
